<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #box{
            width: 100px;
            height: 100px;
            background-color: #f00;
        }
    </style>
</head>
<body>
    <a id="href" href="">超链接</a>
    <div id="box"></div>
    <script>
        let oHref = document.getElementById('href');
        let oBox = document.getElementById('box');
        // 取消默认事件
        oHref.onclick = function(){
            console.log("test msg");
            return false;
        }

        oBox.oncontextmenu = function(){
            oBox.style.background = 'green';
            return false;
        }
    </script>
</body>
</html>